package net.mysoft.budgetsoft.system.action;

import javax.annotation.Resource;

import net.mysoft.budgetsoft.system.pagemodel.FlowNodeClass;
import net.mysoft.budgetsoft.system.service.FlowNodeClassService;
import net.mysoft.framework.base.BaseAction;
import net.mysoft.framework.model.Json;
import net.mysoft.framework.util.ExceptionUtil;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ModelDriven;

/**   
 *  
 * @author dagongPGP v1.0 
 * @link <a href=http://www.dagongsoft.net>北京大公信软科技有限公司</a> 
 *  
 * @version $Revision: 1.00  $Date: 2013-07-08 17:26:13 
 */
@Action(value = "flowNodeClassAction", results = { @Result(name = "flowNodeClass", location = "/platform/system/flowNodeClass.jsp"), @Result(name = "flowNodeClassAdd", location = "/platform/system/flowNodeClassAdd.jsp"), @Result(name = "flowNodeClassEdit", location = "/platform/system/flowNodeClassEdit.jsp"), @Result(name = "flowNodeClassView", location = "/platform/system/flowNodeClassView.jsp")})
@Controller("flowNodeClassAction")
public class FlowNodeClassAction extends BaseAction implements ModelDriven<FlowNodeClass>{

	private static final Logger logger = Logger.getLogger(FlowNodeClassAction.class);
	@Resource
	private FlowNodeClassService flowNodeClassService;
	
	private FlowNodeClass flowNodeClass = new FlowNodeClass();
	
	public FlowNodeClassService getFlowNodeClassService(){
		return this.flowNodeClassService;
	}
	
	public void setFlowNodeClassService(FlowNodeClassService flowNodeClassService){
		this.flowNodeClassService = flowNodeClassService;
	}
	
	public FlowNodeClass getFlowNodeClass(){
		return this.flowNodeClass;
	}
	
	public void setFlowNodeClass(FlowNodeClass flowNodeClass){
		this.flowNodeClass = flowNodeClass;
	}
	
	public FlowNodeClass getModel() {
		return flowNodeClass;
	}
	
	/**
	 * FlowNodeClass列表页面
	 * @return
	 */
	public String flowNodeClass() {
		return "flowNodeClass";
	}
	
	/**
	 * FlowNodeClass查看页面
	 * @return
	 */
	public String flowNodeClassView() {
		return "flowNodeClassView";
	}
	
	/**
	 * FlowNodeClass添加页面
	 * @return
	 */
	public String flowNodeClassAdd() {
		return "flowNodeClassAdd";
	}
	
	/**
	 * FlowNodeClass编辑页面
	 * @return
	 */
	public String flowNodeClassEdit() {
		return "flowNodeClassEdit";
	}
	
	/**
	 * 添加
	 */
	public void add() {
		Json j = new Json();
		try {
			flowNodeClassService.add(flowNodeClass);
			j.setSuccess(true);
			j.setMsg("添加成功!");
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
			j.setMsg("添加失败！");
		}
		super.writeJson(j);
	}
	
	/**
	 * 修改
	 */
	public void edit() {
		Json j = new Json();
		try {
			flowNodeClassService.edit(flowNodeClass);
			j.setSuccess(true);
			j.setMsg("编辑成功!");
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
			j.setMsg("编辑失败！");
		}
		super.writeJson(j);
	}
	
	/**
	 * 删除
	 */
	public void delete() {
		Json j = new Json();
		try {
			flowNodeClassService.delete(flowNodeClass);
			j.setSuccess(true);
			j.setMsg("删除成功！");
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
			j.setMsg("删除失败！");
		}
		super.writeJson(j);
	}
	
	/**
	 * 列表
	 */
	public void datagrid() {
		try {
			super.writeJson(flowNodeClassService.datagrid(flowNodeClass));
		} catch (Exception e) {
			logger.error(ExceptionUtil.getExceptionMessage(e));
		}
	}
}
